import { Component, createVNode, nextTick, render } from 'vue'

function createElement() {
	let container = document.querySelector('.fix_container')
	if (container === null) {
		container = document.createElement('div')
		container.className = 'fix_container'
		document.body.appendChild(container)
	}
	return container
}

export function renderElement(
	customElement: Component,
	options: Record<string, any>
) {
	const el = createElement()
	options.show = true
	options.unmount = function () {
		nextTick(() => {
			document.body.removeChild(el)
		})
	}
	const vm = createVNode(customElement, options)
	// console.log(vm, customElement)
	render(vm, el)
}
